#include <cmath>

#include "vector.h"

// ============================================================================
// CONSTRUCTORES
// ============================================================================

// ----------------------------------------------------------------------------
Vector::Vector() {
	x = 0;
	y = 0;
}
// ----------------------------------------------------------------------------
Vector::Vector(double _x, double _y) {
	x = _x;
	y = _y;
}

// ============================================================================
// PROPIEDADES
// ============================================================================

// ----------------------------------------------------------------------------
double Vector::getX() { return x; }
// ----------------------------------------------------------------------------
double Vector::getY() { return y; }
// ----------------------------------------------------------------------------
double Vector::getNorma() { return sqrt(x*x + y*y); }
// ----------------------------------------------------------------------------
double Vector::getNormaCuadrada() { return x*x + y*y; }

// ============================================================================
// OPERADORES
// ============================================================================

// ----------------------------------------------------------------------------
Vector& Vector::operator-() {
	return *(new Vector(-getX(), -getY()));
}
// ----------------------------------------------------------------------------
Vector& Vector::operator+(Vector vector) {
	return *(new Vector(getX() + vector.getX(), getY() + vector.getY()));
}
// ----------------------------------------------------------------------------
Vector& Vector::operator-(Vector vector) {
	return *(new Vector(getX() - vector.getX(), getY() - vector.getY()));
}
// ----------------------------------------------------------------------------
Vector& Vector::operator*(double alpha) {
	return *(new Vector(getX() * alpha, getY() * alpha));
}
// ----------------------------------------------------------------------------
Vector& Vector::operator/(double alpha) {
	return *(new Vector(getX() / alpha, getY() / alpha));
}
// ----------------------------------------------------------------------------
bool Vector::operator==(Vector vector) {
	return getX() == vector.getX() && getY() == vector.getY();
}
// ----------------------------------------------------------------------------
bool Vector::operator!=(Vector vector) {
	return getX() != vector.getX() || getY() != vector.getY();
}
/*
// ----------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& o, const Vector& vector) {
	return o << "V:[" << getX() << ", " << getY() << "]";
}
*/

// ============================================================================
// FUNCIONES
// ============================================================================

// ----------------------------------------------------------------------------
Vector& CrearConAnguloYNorma(double alpha, double norma) {
	return *(new Vector());
}
